package com.pentakill.mo.auth.role.business.ebo;

import java.io.Serializable;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import com.pentakill.mo.auth.res.vo.ResModel;
import com.pentakill.mo.auth.role.business.ebi.RoleEbi;
import com.pentakill.mo.auth.role.dao.dao.RoleDao;
import com.pentakill.mo.auth.role.vo.RoleModel;
import com.pentakill.mo.util.base.BaseQueryModel;


public class RoleEbo implements RoleEbi{
	
	private RoleDao roleDao;
	public void setRoleDao(RoleDao roleDao) {
		this.roleDao = roleDao;
	}

	//废弃
	public void save(RoleModel rm) {
	
	}

	
	public List<RoleModel> getAll() {
		return roleDao.getAll();
	}

	
	public RoleModel get(Serializable uuid) {
		
		return roleDao.get(uuid);
	}

	//废弃
	public void update(RoleModel rm) {
		
	}

	
	public void delete(RoleModel rm) {
		roleDao.delete(rm);
		
	}

	public List<RoleModel> getAll(BaseQueryModel dqm, Integer pageNum, Integer pageCount) {
		return roleDao.getAll(dqm, pageNum, pageCount);
	}

	public Integer getCount(BaseQueryModel dqm) {
		return roleDao.getCount(dqm);
	}

	public void update(RoleModel rm, long[] resUuids, Long[] menuUuids) {
		Set<ResModel> resModels = new HashSet<ResModel>();
		for (long uuid : resUuids) {
			ResModel temp = new ResModel();
			temp.setUuid(uuid);
			resModels.add(temp);
		}
		
		
		RoleModel temp = roleDao.get(rm.getUuid());
		temp.setName(rm.getName());
		temp.setCode(rm.getCode());
		temp.setResModels(resModels);
	}

	public void seve(RoleModel rm, long[] resUuids, Long[] menuUuids) {
		Set<ResModel> resModels = new HashSet<ResModel>();
		for (long uuid : resUuids) {
			ResModel temp = new ResModel();
			temp.setUuid(uuid);
			resModels.add(temp);
		}
		rm.setResModels(resModels);
		
		
		
		roleDao.add(rm);
	}

	public Set<RoleModel> getName(String role) {
		// TODO Auto-generated method stub
		return roleDao.getName(role);
	}
	
	
	
}
